using System;
using System.Collections.Generic;
using System.Text;

using System.Net;
using System.Net.Sockets;
namespace PlayTime
{
    public struct host
    {
        public UInt32 hostIp;
    };
    public class Communication
    {
        private UdpClient m_udpClient = null;
        //private TcpClient m_tcpClient = null;
        //private TcpListener m_tcpListener;
        public Communication()
        {
            m_udpClient = new UdpClient();
            Byte[] sendBytes = Encoding.ASCII.GetBytes("hello");
            // set address to broadcast address and port to 8001
            IPEndPoint RemoteIpEndPoint = new
            IPEndPoint(IPAddress.Parse("255.255.255.255"), 8001);
            // broadcast data
            m_udpClient.Send(sendBytes, sendBytes.Length, RemoteIpEndPoint);
            //IPEndPoint object will allow us to read datagrams sent from any source.
            RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
            // Blocks until a message returns on this socket from a remote host.
            string returnData = String.Empty;
            do
            {
                Byte[] receiveBytes = m_udpClient.Receive(ref RemoteIpEndPoint);
                returnData = Encoding.ASCII.GetString(receiveBytes);
            } while (returnData != String.Empty);
            // close udp client
        }
        public host[] SearchHost()
        {
            host[] ahost = null;
            return ahost;
        }
    }
}
